home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CyberCrypt192135420.psc / CyberCrypt Self-Extractor edition 8.0 / ctlProgress.ctl (.txt) next >
Encoding:
Visual Basic Form  |  2001-02-10  |  7.0 KB  |  213 lines

  1. VERSION 5.00
  2. Begin VB.UserControl ctlProgress 
  3.    ClientHeight    =   300
  4.    ClientLeft      =   0
  5.    ClientTop       =   0
  6.    ClientWidth     =   4800
  7.    ScaleHeight     =   300
  8.    ScaleWidth      =   4800
  9.    Begin VB.PictureBox picProgress 
  10.       AutoRedraw      =   -1  'True
  11.       ClipControls    =   0   'False
  12.       FillStyle       =   0  'Solid
  13.       Height          =   255
  14.       Left            =   0
  15.       ScaleHeight     =   195
  16.       ScaleWidth      =   4695
  17.       TabIndex        =   0
  18.       Top             =   0
  19.       Width           =   4755
  20.    End
  21. Attribute VB_Name = "ctlProgress"
  22. Attribute VB_GlobalNameSpace = False
  23. Attribute VB_Creatable = True
  24. Attribute VB_PredeclaredId = False
  25. Attribute VB_Exposed = False
  26. Option Explicit
  27. Dim lMaxValue As Long
  28. Dim lMinValue As Long
  29. Dim lValue As Long
  30. Dim sCaption As String
  31. Dim nCaptionStyle As Integer
  32. Dim oFillColor As OLE_COLOR
  33. Public Enum eBorderStyle
  34.     eBor_None = 0
  35.     eBor_FixedSingle
  36. End Enum
  37. Public Enum eCaptionStyle
  38.     eCap_None = 0
  39.     eCap_CaptionOnly
  40.     eCap_PercentOnly
  41.     eCap_CaptionPercent
  42. End Enum
  43. Public Enum eAppearance
  44.     eApp_Flat = 0
  45.     eApp_3D
  46. End Enum
  47. Public Property Let Appearance(nValue As eAppearance)
  48.     picProgress.Appearance = nValue
  49.     PropertyChanged
  50. End Property
  51. Public Property Get Appearance() As eAppearance
  52.     Appearance = picProgress.Appearance
  53. End Property
  54. Public Property Let Caption(nValue As String)
  55.     sCaption = Trim(nValue)
  56.     PropertyChanged
  57. End Property
  58. Public Property Get Caption() As String
  59.     Caption = sCaption
  60. End Property
  61. Public Property Let Max(nValue As Long)
  62.     lMaxValue = nValue
  63.     PropertyChanged
  64. End Property
  65. Public Property Get Max() As Long
  66.     Max = lMaxValue
  67. End Property
  68. Public Property Let Min(nValue As Long)
  69.     lMinValue = nValue
  70.     PropertyChanged
  71. End Property
  72. Public Property Get Min() As Long
  73.     Min = lMinValue
  74. End Property
  75. Public Property Let Enabled(nValue As Boolean)
  76.     picProgress.Enabled = nValue
  77.     PropertyChanged
  78. End Property
  79. Public Property Get Enabled() As Boolean
  80.     Enabled = picProgress.Enabled
  81. End Property
  82. Public Property Let BorderStyle(nValue As eBorderStyle)
  83.     picProgress.BorderStyle = nValue
  84.     PropertyChanged
  85. End Property
  86. Public Property Get BorderStyle() As eBorderStyle
  87.     BorderStyle = picProgress.BorderStyle
  88. End Property
  89. Public Property Let CaptionStyle(nValue As eCaptionStyle)
  90.     nCaptionStyle = nValue
  91.     PropertyChanged
  92. End Property
  93. Public Property Get CaptionStyle() As eCaptionStyle
  94.     CaptionStyle = nCaptionStyle
  95. End Property
  96. Public Property Get CaptionFont() As Font
  97.     Set CaptionFont = UserControl.Font
  98. End Property
  99. Public Property Set CaptionFont(ByVal NewFont As Font)
  100.     Set UserControl.Font = NewFont
  101.     SyncLabelFonts
  102.     PropertyChanged
  103. End Property
  104. Private Sub SyncLabelFonts()
  105.     Dim objCtl As Object
  106.     For Each objCtl In Controls
  107.         Set objCtl.Font = UserControl.Font
  108.     Next
  109. End Sub
  110. Public Property Let FillColor(nValue As OLE_COLOR)
  111.     oFillColor = nValue
  112.     PropertyChanged
  113. End Property
  114. Public Property Get FillColor() As OLE_COLOR
  115.     FillColor = oFillColor
  116. End Property
  117. Public Property Let ForeColor(nValue As OLE_COLOR)
  118.     picProgress.ForeColor = nValue
  119.     PropertyChanged
  120. End Property
  121. Public Property Get ForeColor() As OLE_COLOR
  122.     ForeColor = picProgress.ForeColor
  123. End Property
  124. Public Property Let BackColor(nValue As OLE_COLOR)
  125.     picProgress.BackColor = nValue
  126.     PropertyChanged
  127. End Property
  128. Public Property Get BackColor() As OLE_COLOR
  129.     BackColor = picProgress.BackColor
  130. End Property
  131. Public Property Let Value(nValue As Long)
  132.     lValue = nValue
  133.     Call ChangeValue(nValue)
  134. End Property
  135. Public Property Get Value() As Long
  136.     Value = lValue
  137. End Property
  138. Private Sub Picture(Obj As PictureBox)
  139.     UserControl.Picture = Obj.Picture
  140. End Sub
  141. Private Sub GetPicture(Obj As PictureBox)
  142.     Obj.Picture = UserControl.Picture
  143. End Sub
  144. Public Sub Refresh()
  145.     picProgress.Refresh
  146. End Sub
  147. Private Sub UserControl_InitProperties()
  148.     Max = 100
  149.     Min = 0
  150.     BackColor = UserControl.BackColor
  151.     FillColor = vbBlue
  152.     CaptionStyle = eCap_PercentOnly
  153.     SyncLabelFonts
  154. End Sub
  155. Private Sub UserControl_Resize()
  156.     picProgress.Width = UserControl.Width
  157.     picProgress.Height = UserControl.Height
  158. End Sub
  159. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  160.     On Error Resume Next
  161.     picProgress.Appearance = PropBag.ReadProperty("Appearance", picProgress.Appearance)
  162.     picProgress.ForeColor = PropBag.ReadProperty("ForeColor", picProgress.ForeColor)
  163.     picProgress.BackColor = PropBag.ReadProperty("BackColor", picProgress.BackColor)
  164.     oFillColor = PropBag.ReadProperty("FillColor", oFillColor)
  165.     BorderStyle = PropBag.ReadProperty("BorderStyle", 1)
  166.     CaptionStyle = PropBag.ReadProperty("CaptionStyle", 3)
  167.     Enabled = PropBag.ReadProperty("Enabled", True)
  168.     Caption = PropBag.ReadProperty("Caption", "")
  169.     Max = PropBag.ReadProperty("Max", 100)
  170.     Min = PropBag.ReadProperty("Min", 0)
  171.     Set CaptionFont = PropBag.ReadProperty("CaptionFont")
  172. End Sub
  173. Private Sub ChangeValue(nValue As Long)
  174.     On Error Resume Next
  175.     Dim NewCaption As String
  176.     If nValue > lMaxValue Then
  177.         nValue = lMaxValue
  178.     ElseIf nValue < lMinValue Then
  179.         nValue = lMinValue
  180.     End If
  181.     picProgress.Cls
  182.     If CaptionStyle <> eCap_None Then
  183.         If CaptionStyle <> eCap_CaptionOnly Then
  184.             If Caption = "" Or CaptionStyle = eCap_PercentOnly Then
  185.                 NewCaption = Format(Str((nValue - Min) / (Max - Min)) * 100, "0") + "%"
  186.             Else
  187.                 NewCaption = Caption & " " & Format(Str((nValue - Min) / (Max - Min)) * 100, "0") + "%"
  188.             End If
  189.         Else
  190.             NewCaption = Caption
  191.         End If
  192.     End If
  193.     picProgress.ScaleWidth = Max - Min
  194.     picProgress.DrawMode = 10
  195.     picProgress.CurrentX = (picProgress.ScaleWidth / 2 - picProgress.TextWidth(NewCaption) / 2)
  196.     picProgress.CurrentY = (picProgress.ScaleHeight - picProgress.TextHeight(NewCaption)) / 2
  197.     picProgress.Print NewCaption
  198.     picProgress.Line (0, 0)-((nValue - Min), picProgress.Width), FillColor, BF
  199. End Sub
  200. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  201.     Call PropBag.WriteProperty("Appearance", picProgress.Appearance)
  202.     Call PropBag.WriteProperty("ForeColor", picProgress.ForeColor)
  203.     Call PropBag.WriteProperty("BackColor", picProgress.BackColor)
  204.     Call PropBag.WriteProperty("FillColor", oFillColor)
  205.     Call PropBag.WriteProperty("Font", Font, Ambient.Font)
  206.     Call PropBag.WriteProperty("BorderStyle", BorderStyle, 1)
  207.     Call PropBag.WriteProperty("CaptionStyle", CaptionStyle, 3)
  208.     Call PropBag.WriteProperty("Enabled", Enabled, True)
  209.     Call PropBag.WriteProperty("Caption", Caption)
  210.     Call PropBag.WriteProperty("Min", Min, 0)
  211.     Call PropBag.WriteProperty("CaptionFont", CaptionFont)
  212. End Sub
  213.